#ifndef PTHREAD_POOP_H__
#define PTHREAD_POOP_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdbool.h>

#define NAMESIZE 1024
#define MAXTASK 10
#define TIDMAX 25

struct fileNode
{
	char src[NAMESIZE];
	char dest[NAMESIZE];
};

struct Node
{
	void (*fileTask)(void *args);
	struct fileNode args;
};

typedef struct list_st
{
	struct Node data;
	struct list_st *next;
}list_st;


typedef struct Head_st
{
	struct list_st *first;
	struct list_st *last;
	int node_number;
}Head_st;

typedef struct pthread_pool
{
	pthread_mutex_t mut;
	pthread_cond_t cond;
	Head_st *taskList;
	pthread_t *tids;
	unsigned int activeThreads;
	unsigned int maxWaitingTask;
	unsigned int curWaitingTask;
	bool shutdown;
}pthread_pool;


int listInit(Head_st **ptr);
int listInsert(Head_st **ptr, struct Node data);

int initPool(pthread_pool *pool, unsigned int threadNum);

void *routine(void *args);

int addTask(pthread_pool *pool, struct Node data);

int destroyPool(pthread_pool *pool);

#endif
